﻿// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit)
// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus
// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues
// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE
// More projects: http://www.zzzprojects.com/
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.

using System.Linq;

namespace Z.EntityFramework.Plus
{
#if QUERY_INCLUDEOPTIMIZED
    internal static partial class QueryAddOrAppendOrderExtensions
#else
    public static partial class QueryAddOrAppendOrderExtensions
#endif
    {
        public static IQueryable<T> AddToRootOrAppendOrderBy<T>(this IQueryable<T> query, params string[] columns)
        {
            var visitor = new QueryAddOrAppendOrderExpressionVisitor<T> {AddToRoot = true};
            return visitor.OrderBy(query, columns);
        }
    }
}